using UnityEngine;

public class CarDamage : MonoBehaviour
{
	public AudioClip ClashSound;

	public byte ClashDamage;

	public Car Root;

	public float VelocityThreshold = 3f;

	private void Start()
	{
	}

	private void OnTriggerEnter(Collider collider)
	{
		Rigidbody component = Root.GetComponent<Rigidbody>();
		if ((bool)component)
		{
			if ((bool)Root.Audiosource && (bool)ClashSound && component.velocity.magnitude > VelocityThreshold)
			{
				Root.Audiosource.PlayOneShot(ClashSound);
			}
			DamagePackage damagePackage = default(DamagePackage);
			damagePackage.Damage = (byte)((float)(int)ClashDamage * component.velocity.magnitude);
			damagePackage.Normal = component.velocity.normalized;
			damagePackage.Direction = component.velocity * 2f;
			damagePackage.Position = base.transform.position;
			if (Root.Seats[0].passenger != null)
			{
				damagePackage.ID = (int)Root.Seats[0].passenger.netId.Value;
			}
			else
			{
				damagePackage.ID = -1;
			}
			damagePackage.Team = 3;
			damagePackage.DamageType = 0;
			collider.gameObject.transform.root.SendMessage("DirectDamage", damagePackage, SendMessageOptions.DontRequireReceiver);
		}
	}
}
